home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_09 / xmpl_04.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  752 b   |  42 lines  |  [TEXT/R*ch]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 9, example 4
  5.  
  6. -- create the initial module with the exported variables 
  7. -- x, y and z
  8.  
  9. module XYZ
  10.     uses ScriptX
  11.     exports x, y, z
  12. end
  13. in module XYZ
  14. global x := 10
  15. global y := "foo"
  16. global z := #(56,567)
  17.  
  18. -- Now create a module that uses XYZ and imports all the 
  19. -- variables from it.
  20.  
  21. module XYZimport1
  22.     uses ScriptX
  23.     uses XYZ with imports everything end
  24. end
  25. in module XYZimport1
  26. print x
  27. print y
  28. print z
  29.  
  30. -- Here's a third module that imports only x and z
  31. -- note that y is undefined within the context of this module.
  32.  
  33. module XYZimport2
  34.     uses ScriptX
  35.     uses XYZ with imports x, z end
  36. end
  37. in module XYZimport2
  38. print x
  39. print z
  40. -- this should generate an exception
  41. print y
  42. -->>>